//
//  BaseTbv.m
//  ZITHER
//
//  Created by weixin on 2018/10/11.
//  Copyright © 2018年 weixn. All rights reserved.
//

#import "BaseTbv.h"


@interface BaseTbv()



@end

@implementation BaseTbv

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.noMoreDateView];
//        [self.noMoreDateView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.left.right.bottom.equalTo(self).offset(0);
//        }];
    }
    return self;
}

/**
 大小
 是否有mj加载控件 0 or niu没有  1：两个都有 2:只有下拉 3:只有上啦
 是否是约束设置cell高度 还是 给代理添加cell高度
 注册cell
 */

-(instancetype)initializeFrame:(CGRect)frame isMj:(NSInteger)isMj isEstimatedRowHeight:(BOOL)estimatedRowHeight addRegisterNib:(NSArray<NSString*>*)arr{
    
    [self init].frame = frame;

    @weakify(self);

    if (isMj == 1){
        self.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
            @strongify(self);
            self.page ++;
            [self Starefreshing];
        }];
        self.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
            @strongify(self);
            self.page = 0;
            [self Starefreshing];
        }];
    }else if (isMj == 2){
        self.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
            @strongify(self);
            self.page = 0;
            [self Starefreshing];
        }];
    }else if (isMj == 3){
        self.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
            @strongify(self);
            self.page ++;
            [self Starefreshing];
        }];
    }
    if (estimatedRowHeight) {
        self.estimatedRowHeight = 1000;
        self.rowHeight = UITableViewAutomaticDimension;
    }
    self.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.showsHorizontalScrollIndicator = NO;
    self.showsVerticalScrollIndicator = NO;
    
    
    if (arr) {
        for (NSString *str in arr) {
            [self registerNib:[UINib nibWithNibName:str bundle:nil] forCellReuseIdentifier:str];
        }
    }
    return self;

}

-(void)endRefreshing{
    [self.mj_header endRefreshing];
    [self.mj_footer endRefreshing];
}


-(void)setShowBgView:(BOOL)hidden{
    
}


-(noMoreDateView *)noMoreDateView{
    if (!_noMoreDateView) {
        _noMoreDateView = [[noMoreDateView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
    }
    return _noMoreDateView;
}



-(void)setNoMoreDataBg:(BOOL)type NoDataState:(NoMoreDataState)NoDataState{
    self.scrollEnabled = type;
    [self.noMoreDateView setNoMoreDataBg:type NoDataState:NoDataState];

}

-(void)Starefreshing{
    
}
@end
